package com.yangtzeu.jwc.customview;

import android.app.Dialog;
import android.content.Context;
import android.view.Gravity;
import android.widget.ProgressBar;
import android.widget.TextView;

import com.zhangdi.jwc.R;

public class CustomeDownloadDialog extends Dialog {
    private Context context = null;
    private static CustomeDownloadDialog customDownloadDialog = null;

    public CustomeDownloadDialog(Context context) {
	super(context);
	this.context = context;
    }

    public CustomeDownloadDialog(Context context, int theme) {
	super(context, theme);
    }

    public static CustomeDownloadDialog createDialog(Context context, android.view.View.OnClickListener listener) {
	customDownloadDialog = new CustomeDownloadDialog(context, R.style.theme_customer_progress_dialog);
	customDownloadDialog.setContentView(R.layout.custom_download_dialog_layout);
	customDownloadDialog.getWindow().getAttributes().gravity = Gravity.CENTER;
	TextView tv = (TextView) customDownloadDialog.findViewById(R.id.dialog_title);
	tv.setText("正在下载");
	customDownloadDialog.findViewById(R.id.download_cancel).setOnClickListener(listener);
	return customDownloadDialog;
    }

    public void setProgress(int progress) {
	TextView tv = (TextView) findViewById(R.id.download_percent_text);
	ProgressBar pb = (ProgressBar) findViewById(R.id.download_percent_bar);
	tv.setText(progress+"%");
	pb.setProgress(progress);
    }

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
	if (customDownloadDialog == null) {
	    return;
	}
    }
}
